package com.cloudlibrary.service.impl;

import com.cloudlibrary.PageResult.PageResult;
import com.cloudlibrary.domain.Book;
import com.cloudlibrary.mapper.BookMapper;
import com.cloudlibrary.service.BookService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class BookServiceImpl implements BookService {
    @Autowired
    private BookMapper bookMapper;
    @Override
    public PageResult selectNewBooks(Integer PageNum,Integer pageSize){
        PageHelper.startPage(PageNum,pageSize);
        Page<Book> page=bookMapper.selectNewBooks();
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public Book findById(String id) {
        return null;
    }

    @Override
    public Integer borrowBook(Book book) {
        return 0;
    }
}
